        <!DOCTYPE html>
        <html>
        <head>
                <meta charset="utf-8">
        <title>DistanceJointDef class / box2d_html Library / Dart Documentation</title>
        <link rel="stylesheet" type="text/css"
            href="../styles.css">
        <link href="http://fonts.googleapis.com/css?family=Open+Sans:400,600,700,800" rel="stylesheet" type="text/css">
        <link rel="shortcut icon" href="../favicon.ico">
        
        </head>
        <body data-library="box2d_html" data-type="DistanceJointDef">
        <div class="page">
        <div class="header">
          <a href="../index.html"><div class="logo"></div></a>
          <a href="../index.html">Dart Documentation</a>
         &rsaquo; <a href="../box2d_html.html">box2d_html</a> &rsaquo; <a href="../box2d_html/DistanceJointDef.html">DistanceJointDef</a>        <div id="search-box">
          <input type="search" name="q" id="q" autocomplete="off"
              class="search-input" placeholder="Search API">
        </div>
        
      </div>
      <div class="drop-down" id="drop-down"></div>
      
        <div class="nav">
        
</div>
<div class="content">
        <h2><strong>DistanceJointDef</strong>
          class
        </h2>
        
<button id="show-inherited" class="show-inherited">Hide inherited</button>
<div class="doc">
<p>Distance joint definition. This requires defining an
anchor point on both bodies and the non-zero length of the
distance joint. The definition uses local anchor points
so that the initial configuration can violate the constraint
slightly. This helps when saving and loading a game.
Warning: Do not use a zero or short length.</p>
<pre class="source">
class DistanceJointDef extends JointDef {
  /** The local anchor point relative to body1's origin. */
  final Vector localAnchorA;

  /** The local anchor point relative to body2's origin. */
  final Vector localAnchorB;

  /** The equilibrium length between the anchor points. */
  num length;

  /**
   * The mass-spring-damper frequency in Hertz.
   */
  num frequencyHz;

  /**
   * The damping ratio. 0 = no damping, 1 = critical damping.
   */
  num dampingRatio;

  DistanceJointDef() :
    super(),
    localAnchorA = new Vector(0.0, 0.0),
    localAnchorB = new Vector(0.0, 0.0),
    length = 1.0,
    frequencyHz = 0.0,
    dampingRatio = 0.0 {
    type = JointType.DISTANCE;
  }

  /**
   * Initialize the bodies, anchors, and length using the world
   * anchors.
   * b1: First body
   * b2: Second body
   * anchor1: World anchor on first body
   * anchor2: World anchor on second body
   */
  void initialize(Body b1, Body b2, Vector anchor1, Vector anchor2) {
    bodyA = b1;
    bodyB = b2;
    localAnchorA.setFrom(bodyA.getLocalPoint(anchor1));
    localAnchorB.setFrom(bodyB.getLocalPoint(anchor2));
    Vector d = new Vector.copy(anchor2);
    d.subLocal(anchor1);
    length = d.length;
  }
}
</pre>
</div>
<h3>Extends</h3>
<p>
<span class="type-box"><span class="icon-class"></span><a href="../box2d_html/JointDef.html">JointDef</a></span>&nbsp;&gt;&nbsp;<span class="type-box"><span class="icon-class"></span><strong>DistanceJointDef</strong></span></p>
<div>
<h3>Constructors</h3>
<div class="method"><h4 id="DistanceJointDef">
<button class="show-code">Code</button>
new <strong>DistanceJointDef</strong>() <a class="anchor-link" href="#DistanceJointDef"
              title="Permalink to DistanceJointDef.DistanceJointDef">#</a></h4>
<div class="doc">
<pre class="source">
DistanceJointDef() :
  super(),
  localAnchorA = new Vector(0.0, 0.0),
  localAnchorB = new Vector(0.0, 0.0),
  length = 1.0,
  frequencyHz = 0.0,
  dampingRatio = 0.0 {
  type = JointType.DISTANCE;
}
</pre>
</div>
</div>
</div>
<div>
<h3>Properties</h3>
<div class="field inherited"><h4 id="bodyA">
<button class="show-code">Code</button>
<a href="../box2d_html/Body.html">Body</a>         <strong>bodyA</strong> <a class="anchor-link"
            href="#bodyA"
            title="Permalink to DistanceJointDef.bodyA">#</a>
        </h4>
        <div class="inherited-from">inherited from <a href="../box2d_html/JointDef.html">JointDef</a> </div><div class="doc">
<p>The first attached body.</p>
<pre class="source">
Body bodyA;
</pre>
</div>
</div>
<div class="field inherited"><h4 id="bodyB">
<button class="show-code">Code</button>
<a href="../box2d_html/Body.html">Body</a>         <strong>bodyB</strong> <a class="anchor-link"
            href="#bodyB"
            title="Permalink to DistanceJointDef.bodyB">#</a>
        </h4>
        <div class="inherited-from">inherited from <a href="../box2d_html/JointDef.html">JointDef</a> </div><div class="doc">
<p>The second attached body.</p>
<pre class="source">
Body bodyB;
</pre>
</div>
</div>
<div class="field inherited"><h4 id="collideConnected">
<button class="show-code">Code</button>
bool         <strong>collideConnected</strong> <a class="anchor-link"
            href="#collideConnected"
            title="Permalink to DistanceJointDef.collideConnected">#</a>
        </h4>
        <div class="inherited-from">inherited from <a href="../box2d_html/JointDef.html">JointDef</a> </div><div class="doc">
<p>Set this flag to true if the attached bodies should collide.</p>
<pre class="source">
bool collideConnected;
</pre>
</div>
</div>
<div class="field"><h4 id="dampingRatio">
<button class="show-code">Code</button>
num         <strong>dampingRatio</strong> <a class="anchor-link"
            href="#dampingRatio"
            title="Permalink to DistanceJointDef.dampingRatio">#</a>
        </h4>
        <div class="doc">
<p>The damping ratio. 0 = no damping, 1 = critical damping.</p>
<pre class="source">
num dampingRatio;
</pre>
</div>
</div>
<div class="field"><h4 id="frequencyHz">
<button class="show-code">Code</button>
num         <strong>frequencyHz</strong> <a class="anchor-link"
            href="#frequencyHz"
            title="Permalink to DistanceJointDef.frequencyHz">#</a>
        </h4>
        <div class="doc">
<p>The mass-spring-damper frequency in Hertz.</p>
<pre class="source">
num frequencyHz;
</pre>
</div>
</div>
<div class="field"><h4 id="length">
<button class="show-code">Code</button>
num         <strong>length</strong> <a class="anchor-link"
            href="#length"
            title="Permalink to DistanceJointDef.length">#</a>
        </h4>
        <div class="doc">
<p>The equilibrium length between the anchor points.</p>
<pre class="source">
num length;
</pre>
</div>
</div>
<div class="field"><h4 id="localAnchorA">
<button class="show-code">Code</button>
final <a href="../box2d_html/Vector.html">Vector</a>         <strong>localAnchorA</strong> <a class="anchor-link"
            href="#localAnchorA"
            title="Permalink to DistanceJointDef.localAnchorA">#</a>
        </h4>
        <div class="doc">
<p>The local anchor point relative to body1's origin.</p>
<pre class="source">
final Vector localAnchorA;
</pre>
</div>
</div>
<div class="field"><h4 id="localAnchorB">
<button class="show-code">Code</button>
final <a href="../box2d_html/Vector.html">Vector</a>         <strong>localAnchorB</strong> <a class="anchor-link"
            href="#localAnchorB"
            title="Permalink to DistanceJointDef.localAnchorB">#</a>
        </h4>
        <div class="doc">
<p>The local anchor point relative to body2's origin.</p>
<pre class="source">
final Vector localAnchorB;
</pre>
</div>
</div>
<div class="field inherited"><h4 id="runtimeType">
<button class="show-code">Code</button>
final Type         <strong>runtimeType</strong> <a class="anchor-link"
            href="#runtimeType"
            title="Permalink to DistanceJointDef.runtimeType">#</a>
        </h4>
        <div class="inherited-from">inherited from Object </div><div class="doc">
<p>A representation of the runtime type of the object.</p>
<pre class="source">
external Type get runtimeType;
</pre>
</div>
</div>
<div class="field inherited"><h4 id="type">
<button class="show-code">Code</button>
int         <strong>type</strong> <a class="anchor-link"
            href="#type"
            title="Permalink to DistanceJointDef.type">#</a>
        </h4>
        <div class="inherited-from">inherited from <a href="../box2d_html/JointDef.html">JointDef</a> </div><div class="doc">
<p>The joint type is set automatically for concrete joint types.</p>
<pre class="source">
int type;
</pre>
</div>
</div>
<div class="field inherited"><h4 id="userData">
<button class="show-code">Code</button>
Object         <strong>userData</strong> <a class="anchor-link"
            href="#userData"
            title="Permalink to DistanceJointDef.userData">#</a>
        </h4>
        <div class="inherited-from">inherited from <a href="../box2d_html/JointDef.html">JointDef</a> </div><div class="doc">
<p>Use this to attach application specific data to your joints.</p>
<pre class="source">
Object userData;
</pre>
</div>
</div>
</div>
<div>
<h3>Operators</h3>
<div class="method inherited"><h4 id="==">
<button class="show-code">Code</button>
bool <strong>operator ==</strong>(other) <a class="anchor-link" href="#=="
              title="Permalink to DistanceJointDef.operator ==">#</a></h4>
<div class="inherited-from">inherited from Object </div><div class="doc">
<p>The equality operator.</p>
<p>The default behavior for all <code>Object</code>s is to return true if and
only if <code>this</code> and 
<span class="param">other</span> are the same object.</p>
<p>If a subclass overrides the equality operator it should override
the <code>hashCode</code> method as well to maintain consistency.</p>
<pre class="source">
bool operator ==(other) =&gt; identical(this, other);
</pre>
</div>
</div>
</div>
<div>
<h3>Methods</h3>
<div class="method"><h4 id="DistanceJointDef">
<button class="show-code">Code</button>
new <strong>DistanceJointDef</strong>() <a class="anchor-link" href="#DistanceJointDef"
              title="Permalink to DistanceJointDef.DistanceJointDef">#</a></h4>
<div class="doc">
<pre class="source">
DistanceJointDef() :
  super(),
  localAnchorA = new Vector(0.0, 0.0),
  localAnchorB = new Vector(0.0, 0.0),
  length = 1.0,
  frequencyHz = 0.0,
  dampingRatio = 0.0 {
  type = JointType.DISTANCE;
}
</pre>
</div>
</div>
<div class="method inherited"><h4 id="hashCode">
<button class="show-code">Code</button>
int <strong>hashCode</strong>() <a class="anchor-link" href="#hashCode"
              title="Permalink to DistanceJointDef.hashCode">#</a></h4>
<div class="inherited-from">inherited from Object </div><div class="doc">
<p>Get a hash code for this object.</p>
<p>All objects have hash codes. Hash codes are guaranteed to be the
same for objects that are equal when compared using the equality
operator <code>==</code>. Other than that there are no guarantees about
the hash codes. They will not be consistent between runs and
there are no distribution guarantees.</p>
<p>If a subclass overrides <code>hashCode</code> it should override the
equality operator as well to maintain consistency.</p>
<pre class="source">
external int hashCode();
</pre>
</div>
</div>
<div class="method"><h4 id="initialize">
<button class="show-code">Code</button>
void <strong>initialize</strong>(<a href="../box2d_html/Body.html">Body</a> b1, <a href="../box2d_html/Body.html">Body</a> b2, <a href="../box2d_html/Vector.html">Vector</a> anchor1, <a href="../box2d_html/Vector.html">Vector</a> anchor2) <a class="anchor-link" href="#initialize"
              title="Permalink to DistanceJointDef.initialize">#</a></h4>
<div class="doc">
<p>Initialize the bodies, anchors, and length using the world
anchors.
b1: First body
b2: Second body
anchor1: World anchor on first body
anchor2: World anchor on second body</p>
<pre class="source">
void initialize(Body b1, Body b2, Vector anchor1, Vector anchor2) {
  bodyA = b1;
  bodyB = b2;
  localAnchorA.setFrom(bodyA.getLocalPoint(anchor1));
  localAnchorB.setFrom(bodyB.getLocalPoint(anchor2));
  Vector d = new Vector.copy(anchor2);
  d.subLocal(anchor1);
  length = d.length;
}
</pre>
</div>
</div>
<div class="method inherited"><h4 id="JointDef">
<button class="show-code">Code</button>
new <strong>JointDef</strong>() <a class="anchor-link" href="#JointDef"
              title="Permalink to DistanceJointDef.JointDef">#</a></h4>
<div class="inherited-from">inherited from <a href="../box2d_html/JointDef.html">JointDef</a> </div><div class="doc">
<pre class="source">
JointDef() :
  type = JointType.UNKNOWN,
  userData = null,
  bodyA = null,
  bodyB = null,
  collideConnected = false { }
</pre>
</div>
</div>
<div class="method inherited"><h4 id="noSuchMethod">
<button class="show-code">Code</button>
<strong>noSuchMethod</strong>(String name, List args) <a class="anchor-link" href="#noSuchMethod"
              title="Permalink to DistanceJointDef.noSuchMethod">#</a></h4>
<div class="inherited-from">inherited from Object </div><div class="doc">
<p><code>noSuchMethod</code> is invoked when users invoke a non-existant method
on an object. The name of the method and the arguments of the
invocation are passed to <code>noSuchMethod</code>. If <code>noSuchMethod</code>
returns a value, that value becomes the result of the original
invocation.</p>
<p>The default behavior of <code>noSuchMethod</code> is to throw a
<code>noSuchMethodError</code>.</p>
<pre class="source">
external Dynamic noSuchMethod(String name, List args);
</pre>
</div>
</div>
<div class="method inherited"><h4 id="Object">
<button class="show-code">Code</button>
const <strong>Object</strong>() <a class="anchor-link" href="#Object"
              title="Permalink to DistanceJointDef.Object">#</a></h4>
<div class="inherited-from">inherited from Object </div><div class="doc">
<p>Creates a new <code>Object</code> instance.</p>
<p><code>Object</code> instances have no meaningful state, and are only useful
through their identity. An <code>Object</code> instance is equal to itself
only.</p>
<pre class="source">
const Object();
</pre>
</div>
</div>
<div class="method inherited"><h4 id="toString">
<button class="show-code">Code</button>
String <strong>toString</strong>() <a class="anchor-link" href="#toString"
              title="Permalink to DistanceJointDef.toString">#</a></h4>
<div class="inherited-from">inherited from Object </div><div class="doc">
<p>Returns a string representation of this object.</p>
<pre class="source">
external String toString();
</pre>
</div>
</div>
</div>
        </div>
        <div class="clear"></div>
        </div>
        
        <div class="footer">
          
        </div>
        <script async src="../client-live-nav.js"></script>
        </body></html>
        
